package de.medieninf.webanw;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.MathContext; // stellengenauigkeit, rundung der BigDecimal-Objekte setzen
import java.util.ArrayList;

public class RechnerBean implements Serializable{
	private static final long serialVersionUID = 2L;
	private BigDecimal grundwaehrung;
	private MathContext mc;
	private String[] waehrungen;
	private String waehrung1;
	private String waehrung2;
	
	// BigDecimal zielwaehrung;
	private BigDecimal kurs;
	
	public RechnerBean(){
		mc = MathContext.DECIMAL128;		
		String standardGw = "1";
		String standardKurs = "1.25"; // Euro -> USD default
		setGrundwaehrung(standardGw);
		setKurs(standardKurs);
		setWaerungen("Euro,Dollar,Rubel,Peso");
		String waehrung1 = getWaehrungen()[0];
		String waehrung2 = getWaehrungen()[1];
		setWaehrung1(waehrung1);
		setWaehrung2(waehrung2);
		
	}
	
	public String getWaehrung1() {
		return waehrung1;
	}

	public void setWaehrung1(String waehrung1) {
		this.waehrung1 = waehrung1;
	}

	public String getWaehrung2() {
		return waehrung2;
	}

	public void setWaehrung2(String waehrung2) {
		this.waehrung2 = waehrung2;
	}

	public String[] getWaehrungen() {
		return waehrungen;
	}
	public void setWaerungen(String s) {
		this.waehrungen = s.split(",");
	}
	
	public BigDecimal getZielwaehrung() {
		return getGrundwaehrung().multiply(getKurs());
	}

	public void setKurs(String kurs) {		
		this.kurs = new BigDecimal(kurs, mc);
	}
	public BigDecimal getKurs() {
		return kurs;
	}
	
	public void setGrundwaehrung(String grundwaehrung) {
		this.grundwaehrung = new BigDecimal(grundwaehrung, mc);
	}
	
	public BigDecimal getGrundwaehrung() {
		return grundwaehrung;
	}
}
